package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.plan.ScreenDutyPlanDTO;
import com.hzeport.bgs22emduty.dto.plan.ScreenDutyPlanRemoveDTO;
import com.hzeport.bgs22emduty.dto.plan.ScreenDutyPlanSaveDTO;
import com.hzeport.bgs22emduty.entity.ScreenDutyPlan;
import com.hzeport.bgs22emduty.service.ScreenDutyPlanService;
import com.hzeport.bgs22emduty.vo.ScreenStandard.ScreenStandSortVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screendutyplan")
@Api(value = "screendutyplan", tags = "预案库管理")
@Slf4j
public class ScreenDutyPlanController {

    private final ScreenDutyPlanService screenDutyPlanService;

    private final LoginCompoentService loginCompoentService;
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult getScreenDutyPlanPage(@RequestBody ScreenDutyPlanDTO screenDutyPlan) {
        Page<ScreenDutyPlan>  dutyMessageList=screenDutyPlanService.getScreenDutyPlanPage(screenDutyPlan);
        return BaseResult.ok(dutyMessageList);
    }


    /**
     **
     * 通过id查询${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("getById")
    public BaseResult getById(@RequestParam("id") String id) {
        return BaseResult.ok(screenDutyPlanService.detail(id));
    }

    /**
     * 新增${comments}
     * @param screenDutyPlan ${comments}
     * @return R
     */
    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    //@SysLog(.*)
    @PostMapping("save")
    @OperLog(systemName = "YAKGL",description = "YABC")
    public BaseResult save(@Valid@RequestBody ScreenDutyPlanSaveDTO screenDutyPlanSaveDTO) {
        return BaseResult.ok(screenDutyPlanService.savePlans(screenDutyPlanSaveDTO));
    }
//
//    /**
//     * 修改${comments}
//     * @param screenDutyPlan ${comments}
//     * @return R
//     */
//    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
//    //@SysLog(.*)
//    @PostMapping("updateById")
//    public BaseResult updateById(@RequestBody ScreenDutyPlan screenDutyPlan) {
//        return BaseResult.ok(screenDutyPlanService.updateById(screenDutyPlan));
//    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    //@SysLog(.*)
    @PostMapping("/delete")
    @OperLog(systemName = "YAKGL",description = "YASC")
    public BaseResult remove(@Valid @RequestBody ScreenDutyPlanRemoveDTO screenDutyPlanRemoveDTO) {
        return BaseResult.ok(screenDutyPlanService.remove(screenDutyPlanRemoveDTO));
    }
    @ApiOperation( value = "序号排序" )
    @RequestMapping( value = "saveSort", method = RequestMethod.POST )
    @OperLog(systemName = "YAKGL",description = "YAPX")
    public BaseResult updatesort( @RequestBody ScreenStandSortVO screenStandardSort ) {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenDutyPlanService.saveSort( screenStandardSort , userInfoDetailVO );
    }
}
